package org.wlldTest.lesson6;

import org.dromara.easyai.randomForest.DataTable;
import org.dromara.easyai.randomForest.Tree;
import org.dromara.easyai.randomForest.TreeWithTrust;
import org.wlldTest.MySql.Sql;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Test {
    private static Tree tree = null;

    public static void main(String[] args) throws Exception {
     study();
     test();
    }

    public static void test() throws Exception {
        Apple apple = new Apple();
        apple.setColor(1);
        apple.setTac(1);
        apple.setStroke(1);
        TreeWithTrust treeWithTrust = tree.judge(apple);
        System.out.println("good:" + treeWithTrust.getType());
        System.out.println("信任度:" + treeWithTrust.getTrust());
    }

    public static void study() throws Exception {
        Set<String> parameter = new HashSet<>();
        parameter.add("color");
        parameter.add("tac");
        parameter.add("stroke");
        parameter.add("good");
        DataTable dataTable = new DataTable(parameter);
        dataTable.setKey("good");
        List<Apple> appleList = Sql.sql().getSql().selectList("selectApple");
        for (Apple apple : appleList) {
            dataTable.insert(apple);//输入数据
        }
        tree = new Tree(dataTable, 0.1f);
        tree.study();
    }

}
